package com.product;

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.dao.ProductDao;

public class Product_Detele extends HttpServlet {

	
	public void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		int id = 0,flag=0;
		if(request.getParameter("did") != null){
			try {
				id = Integer.parseInt(request.getParameter("did"));
			} catch (Exception e) {
				// TODO: handle exception
			}
			
		}
		ProductDao dao = new ProductDao();
		try {
			flag = dao.detele(id);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		if(flag > 0){
			response.sendRedirect("product_view");
			
		}else{
			response.sendRedirect("manage/err.jsp");
		}
	}

	
	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

		doGet(request, response);
	}

}
